﻿namespace KingerRobot.MexicoSailunMDC.SpiService;
internal interface ITaskCmd
{

    int UpdateOutCmdStatus();
    /// <summary>
    /// 获取指令
    /// </summary>
    /// <param name="cmdId"></param>
    /// <returns></returns>
    POWcsTaskCmd GetTaskCmdById(long cmdId);


    /// <summary>
    /// 根据任务Id修改指定指令类型的状态
    /// </summary>
    /// <param name="taskId"></param>
    /// <param name="status"></param>
    /// <param name="type"></param>
    /// <returns></returns>
    int UpdateCmdStatusByTaskIdAndType(long taskId, int status, int type);
    /// <summary>
    /// 创建任务命令
    /// </summary>
    /// <param name="pOWcsTaskCmd">任务命令模型</param>
    /// <returns>任务命令</returns>
    POWcsTaskCmd CreateTaskCmd(POWcsTaskCmd pOWcsTaskCmd);
    /// <summary>
    /// 设备获取任务
    /// </summary>
    /// <param name="equipId"></param>
    /// <returns></returns>
    POWcsTaskCmd GetTaskCmdByEquipId(long equipId);

    // 查找所有可执行指令
    List<POWcsTaskCmd> GetExecutableTaskCmds();
    /// <summary>
    /// 通过货叉获取未执行任务
    /// </summary>
    /// <param name="equipId"></param>
    /// <returns></returns>
    POWcsTaskCmd GetExecutableTaskCmdByEquipId(long equipId);
    /// <summary>
    /// 通过货叉获取已执行任务
    /// </summary>
    /// <param name="equipId"></param>
    /// <returns></returns>
    POWcsTaskCmd GetExecutedTaskCmdByEquipId(long equipId);
    /// <summary>
    /// 通过taskId获取任务命令信息
    /// </summary>
    /// <param name="taskId">任务ID</param>
    /// <returns>任务命令信息</returns>
    POWcsTaskCmd GetTaskCmdByTaskId(long taskId);
    /// <summary>
    /// 通过taskNo获取任务命令信息
    /// </summary>
    /// <param name="taskNo"></param>
    /// <returns></returns>
    POWcsTaskCmd GetTaskCmdByTaskNo(int taskNo);
    /// <summary>
    /// 通过taskNo获取任务命令列表
    /// </summary>
    /// <param name="taskNo"></param>
    /// <returns></returns>
    List<POWcsTaskCmd> GetTaskCmdListByTaskNo(int taskNo);
    /// <summary>
    /// 是否喷涂
    /// </summary>
    /// <param name="taskNo"></param>
    /// <returns></returns>
    int IsSprayByTaskNo(int taskNo);
    /// <summary>
    /// 通过taskNo获取"可下发"状态任务命令
    /// </summary>
    /// <param name="taskNo"></param>
    /// <returns></returns>
    POWcsTaskCmd GetExecutableTaskCmdByTaskNo(int taskNo);

    POWcsTaskCmd GetEmsExecutableTaskCmdByTaskNo(int taskNo);
    /// <summary>
    /// 通过taskNo获取"已下发"状态任务命令
    /// </summary>
    /// <param name="taskNo"></param>
    /// <returns></returns>
    POWcsTaskCmd GetExecutedTaskCmdByTaskNo(int taskNo);
    /// <summary>
    /// 备份并删除任务命令
    /// </summary>
    /// <param name="taskId"></param>
    /// <returns></returns>
    int BakAndDeleteCmd(long taskId);
    /// <summary>
    /// 修改任务命令状态
    /// </summary>
    /// <param name="taskId">任务ID</param>
    /// <param name="status">状态</param>
    int UpdateTaskCmdStatus(long locId, long taskId, int status);
    /// <summary>
    /// 修改任务状态
    /// </summary>
    /// <param name="taskIds"></param>
    /// <param name="status"></param>
    /// <returns></returns>
    int UpdateTaskCmdStatusByTaskIds(List<long> taskIds, int status);
    /// <summary>
    /// 修改任务命令等待状态
    /// </summary>
    /// <param name="equipId">任务ID</param>
    /// <param name="wait">状态</param>
    int UpdateTaskCmdPairWait(long equipId, int wait);

    /// <summary>
    /// 修改指令目标
    /// </summary>
    /// <param name="id">任务ID</param>
    /// <param name="targetLoc">目标位</param>
    int UpdateCmdTargetLoc(long id, long targetLoc);
    /// <summary>
    /// 修改开始位置
    /// </summary>
    /// <param name="id"></param>
    /// <param name="startLoc"></param>
    /// <returns></returns>
    int UpdateCmdStartLoc(long id, long startLoc);
    /// <summary>
    /// 删除任务命令
    /// </summary>
    /// <param name="taskId">任务ID</param>
    /// <returns></returns>
    int DeleteTaskCmdByTaskId(long taskId);

    /// <summary>
    /// 备份任务命令
    /// </summary>
    /// <param name="taskId"></param>
    /// <returns></returns>
    int BakTaskCmdByTaskId(long taskId);
    /// <summary>
    /// 通过条码获取指令
    /// </summary>
    /// <param name="productCode"></param>
    /// <returns></returns>
    POWcsTaskCmd GetTaskCmdByProductCode(string productCode);

    /// <summary>
    /// 通过产品编号获取是否有任务
    /// </summary>
    /// <param name="productCode"></param>
    /// <returns></returns>
    long GetTaskCmdIdByProductCode(string productCode);

    /// <summary>
    /// 通过开始位置获取下一个进硫化任务
    /// </summary>
    /// <param name="locId">开始位置</param>
    /// <returns></returns>
    POWcsTaskCmd GetNextTaskCmdByLocId(long locId);
    /// <summary>
    /// 通过扫描位置获取下一个进硫化任务
    /// </summary>
    /// <param name="scanLocId"></param>
    POWcsTaskCmd GetNextTaskCmdByScanLocId(long scanLocId);
    /// <summary>
    /// 查找此位置下一条胎的任务
    /// </summary>
    /// <param name="scanLocId"></param>
    /// <param name="emsLoc"></param>
    /// <param name="scannerTime"></param>
    /// <returns></returns>
    POWcsTaskCmd GetNextTaskCmdByScanLocId(long scanLocId, long emsLoc, DateTime scannerTime);
    /// <summary>
    /// 上一条
    /// </summary>
    /// <param name="locId"></param>
    /// <returns></returns>
    POWcsTaskCmd GetUpTaskCmdByLocId(long locId);
    /// <summary>
    /// 通过等待状态查询
    /// </summary>
    /// <param name="pairWait">等待</param>
    /// <returns></returns>
    POWcsTaskCmd GetNextTaskCmdByPairWait(long startLoc, int pairWait);
    ///// <summary>
    ///// 通过开始位置获取下一个进硫化未执行任务
    ///// </summary>
    ///// <param name="locId"></param>
    ///// <returns></returns>
    //POWcsTaskCmd GetNextExecutableTaskCmdByLocId(long locId);
    /// <summary>
    /// 通过位置获取是否有任务
    /// </summary>
    /// <param name="locId"></param>
    /// <returns></returns>
    long GetExecutableTaskIdkByStartLocId(long locId);
    /// <summary>
    /// 结束位置任务总数
    /// </summary>
    /// <param name="locIds"></param>
    /// <returns></returns>
    int GetTaskCmdCountByLocs(List<long> locIds);
    /// <summary>
    /// 出库查找是否有任务
    /// </summary>
    /// <param name="locId"></param>
    /// <returns></returns>
    long GetOutPutExecutableTaskIdkByLocId(long locId, long taskId);
    /// <summary>
    /// 通过设备查询是否有未完成指令
    /// </summary>
    /// <param name="equipId">设备Id</param>
    /// <returns>是否有任务</returns>
    bool IsTaskCmdByEquipId(long equipId);
    /// <summary>
    /// 通过设备查询正在执行指令
    /// </summary>
    /// <param name="equipIds"></param>
    /// <returns></returns>
    bool IsExecutedTaskCmdByEquipIds(List<long> equipIds);
    /// <summary>
    /// 通过任务类型货位指令信息
    /// </summary>
    /// <param name="enumTaskType"></param>
    /// <returns></returns>
    List<TaskInfoBean> GetIOExecutableWcsTaskCmdsByType(EnumTaskType enumTaskType);

    List<TaskInfoBean> GetWarehouingIOExecutableWcsTaskCmdsByType(EnumTaskType enumTaskType);
    /// <summary>
    /// 开始位置和流水号查询
    /// </summary>
    /// <param name="startLoc"></param>
    /// <param name="taskNo"></param>
    /// <returns></returns>
    POWcsTaskCmd GetTaskCmdByStartLocAndCode(long startLoc, int taskNo);

    /// <summary>
    /// 目标位置任务汇总
    /// </summary>
    /// <returns>目标汇总数量</returns>
    List<TaskGroupCount> GetTargetLocTaskGroup();
    /// <summary>
    /// 目标位置 可执行任务汇总
    /// </summary>
    /// <returns>目标汇总数量</returns>
    List<TaskGroupCount> GetExecutableTargetLocTaskGroup();
    /// <summary>
    /// 目标位查找指令
    /// </summary>
    /// <param name="locId"></param>
    /// <returns></returns>
    List<POWcsTaskCmd> GetTaskCmdByTargetLocId(long locId);
    /// <summary>
    /// 通过指令开始位查找组
    /// </summary>
    /// <returns></returns>
    List<TaskGroupCount> GetStartLocTaskGroup();
    List<TaskGroupCount> GetStartLocTaskGroupContain(List<long> taskIds);
}